/*
 * All rights Reserved, Designed By Rylynn
 * @ClassName:  Context
 * @Description:
 * @author: rylynn
 * @date:   2021/7/13
 *
 */

package org.etnetwork.engine;

import java.util.Map;
import java.util.Properties;

public class ExecutionContext {
    private Job job;
    private Mode mode;
    private Map<String, Object> cached;

    private ExecutionContext() {

    }

    public static ExecutionContext initExecutionContext(Properties properties) {
        ExecutionContext context = new ExecutionContext();
        if (properties.contains("url")) {
            context.mode = Mode.REMOTE;
        } else {
            context.mode = Mode.STANDALONE;
        }
        return context;
    }

    public static ExecutionContext initExecutionContext() {
        ExecutionContext context = new ExecutionContext();
        return initExecutionContext(new Properties());
    }

    public void writeContext(String key, Object value) {
        this.cached.put(key, value);
    }

    public Object readContext(String key) {
        return this.cached.get(key);
    }


    public void run() {
        
    }

    public Job getJob() {
        return this.job;
    }

    public void setJob(Job job) {
        this.job = job;
    }

    public Mode getMode() {
        return mode;
    }

    public void setMode(Mode mode) {
        this.mode = mode;
    }

    enum Mode {
        STANDALONE, REMOTE
    }
}
